# 海豚调度发送post请求脚本----shell 脚本--等等    TODO

import json
import uuid
import requests
import time
import hashlib

def sendRequest():
    url = '${qiu_url}/test'
    clientId = '${clientId}'
    clientId = '1'
    random = str(uuid.uuid4())
    timestamp = int(time.time() * 1000)
    # dataType = '${dataType}'
    key = "clientId=" + str('${clientId}') + "&random=" + random + "&timestamp=" + str(timestamp)
    hashCode = hashlib.md5(key.encode('utf-8')).hexdigest()

    data = {
        "clientId": clientId,
        "random": random,
        "timestamp": timestamp,
        "key": hashCode,
        # "dataType": dataType
    }
    print(data)
    headers = {
        'Content-Type': 'application/json'
    }

    resource = requests.post(url, data=json.dumps(data), headers=headers)

    if resource.status_code == 200:
       print("success")
       print(resource.text)
    else:
       print("Failed")
       print(resource.text)

if __name__ == '__main__':
    sendRequest()